package cn.mjnxin.iot.client.test;

import cn.mjnxin.iot.base.domain.ChannelData;
import cn.mjnxin.iot.base.domain.SocketData;
import io.netty.buffer.ByteBuf;

/**
 * 主动发送器
 * @author CLG 2023年10月10日
 * @version V1.0.0
 */
public interface ITerminalDataSender {

	void sendChannelData(ChannelData request) throws InterruptedException;

	default void sendMessage(byte[] outData, Integer pid, String remoteAddress) throws InterruptedException {
		SocketData data = new SocketData(outData);
		data.setPid(pid);
		ChannelData response = new ChannelData(remoteAddress, pid, 3, data);
		
		sendChannelData(response);
	}
	
	default void sendMessage(ByteBuf outData) throws InterruptedException {
		SocketData data = new SocketData(outData);
		ChannelData response = new ChannelData(3, data);
		
		sendChannelData(response);
	}
}
